//
//  ExchangeDiscounts.m
//  XJMCustomer
//
//  Created by Mr.hu on 2017/10/13.
//  Copyright © 2017年 Mr.hu. All rights reserved.
//

#import "ExchangeDiscounts.h"

@implementation ExchangeDiscounts

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self == [super initWithFrame:frame]) {
        
        CGFloat widthcancelbind = 270;
        CGFloat heightcancelbind = 246;
        
        UIView * subview = [[UIView alloc]initWithFrame:CGRectMake((ScreenWidth-widthcancelbind)/2, (ScreenHeight - heightcancelbind)/2, widthcancelbind, heightcancelbind)];
        subview.backgroundColor = [UIColor whiteColor];
        subview.layer.cornerRadius = 8;
        [self addSubview:subview];
        
        self.DiscountsConsiderBtn =[[UIButton alloc]init];
        self.DiscountsConsiderBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        self.DiscountsConsiderBtn.layer.cornerRadius = 15;
        self.DiscountsConsiderBtn.layer.masksToBounds = YES;
        [self.DiscountsConsiderBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [self.DiscountsConsiderBtn setBackgroundColor:RGBA(182, 182, 182, 1)];
        [subview addSubview:self.DiscountsConsiderBtn];
        [self.DiscountsConsiderBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.mas_equalTo(-30);
            make.left.mas_equalTo(28);
            make.size.mas_equalTo(CGSizeMake((widthcancelbind-71)/2, 35));
        }];
        
        
        self.DiscountsSureBtn =[[UIButton alloc]init];
        self.DiscountsSureBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        self.DiscountsSureBtn.layer.cornerRadius = 15;
        self.DiscountsSureBtn.layer.masksToBounds = YES;
        [self.DiscountsSureBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [self.DiscountsSureBtn setBackgroundColor:[UIColor colorWithRed:(213)/255.0 green:(32)/255.0 blue:(30)/255.0 alpha:(1)]];
        [subview addSubview:self.DiscountsSureBtn];
        [self.DiscountsSureBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.mas_equalTo(-30);
            make.right.mas_equalTo(-28);
            make.size.mas_equalTo(CGSizeMake((widthcancelbind-71)/2, 35));
        }];
        
        self.leftToplab = [[UILabel alloc]init];
        self.leftToplab.textColor = [UIColor grayColor];
        self.leftToplab.font = [UIFont systemFontOfSize:14];
        self.leftToplab.textAlignment = NSTextAlignmentCenter;
        [subview addSubview:self.leftToplab];
        [self.leftToplab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.DiscountsSureBtn.mas_top).offset(-24);
            make.centerX.mas_equalTo(0);
            make.size.mas_equalTo(CGSizeMake(widthcancelbind,20));
        }];
        
        UIImageView * defaultimage = [[UIImageView alloc]init];
        [defaultimage setImage:[UIImage imageNamed:@"chahua"]];
        [subview addSubview:defaultimage];
        [defaultimage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.leftToplab.mas_top).offset(0);
            make.centerX.mas_equalTo(0);
            make.size.mas_equalTo(CGSizeMake(109.5,100));
        }];
        
        [self.DiscountsConsiderBtn addTarget:self action:@selector(cancelbindingOnclicked) forControlEvents:UIControlEventTouchUpInside];
        
    }
    return self;
}

- (void)cancelbindingOnclicked{
    
    [self removeFromSuperview];
    
}

- (void)ViewDiscountsSureBtn:(NSString *)DiscountsSureBtn DiscountsConsiderBtn:(NSString *)DiscountsConsiderBtn leftToplab:(NSString *)leftToplab{
    
    [self.DiscountsConsiderBtn setTitle:DiscountsConsiderBtn forState:UIControlStateNormal];
    [self.DiscountsSureBtn setTitle:DiscountsSureBtn forState:UIControlStateNormal];
    self.leftToplab.text = leftToplab;
    
}


@end
